import sys

from PySide6.QtCore import Qt
from PySide6.QtWidgets import *
from qfluentwidgets import Signal, TransparentToolButton, FluentIcon


class ReturnView(QFrame):
    returned = Signal()

    def __init__(self, parent=None):
        super().__init__(parent)
        self.vBox = QVBoxLayout(self)
        self.vBox.setContentsMargins(0, 0, 0, 0)
        self.vBox.setSpacing(5)
        self.vBox.setAlignment(Qt.AlignmentFlag.AlignTop)

        # self.hBox = QVBoxLayout()
        # self.hBox.setContentsMargins(0, 0, 0, 0)
        # self.hBox.setSpacing(10)

        self.hBox = QHBoxLayout()
        self.hBox.setContentsMargins(0, 0, 0, 0)
        self.hBox.setSpacing(10)

        self.returnButton = TransparentToolButton(FluentIcon.RETURN, self)
        self.returnButton.setFixedSize(40, 40)
        self.returnButton.clicked.connect(self.returned_event)

        self.hBox.addWidget(self.returnButton, 0, Qt.AlignmentFlag.AlignLeft)
        self.vBox.addLayout(self.hBox)

    def returned_event(self):
        self.returned.emit()
